/*******************************************************/
// ee_hqxaa, Hilda     VS.h for control VS1003 decoder
/*******************************************************/
// with reference to Zhang Qi Bo
// with reference to ICDev MP3 module


#ifndef __VS_H__
#define __VS_H__


#define uchar unsigned char
#define uint  unsigned int


#define DefaultVolume	0x1515
#define DefaultFreq		0xac45			//44.1MHz, stereo
#define CLOCK_REG		0x9800			//write clock register: XTALI*3.0
// clk XTALI on the module is 12.288MHz

#define VS_PORT			PORTD
#define VS_DDR			DDRD
#define VS_PIN			PIND


#define SPI_SCK		1
#define SPI_MOSI	2
#define SPI_MISO	3

#define SPI_PORT		PORTB
#define SPI_DDR			DDRB


// for control port, use PORTD [0:3] DREQ read only for m128
#define VS_XCS			0
#define VS_XRESET		1
#define VS_DREQ			2
#define VS_XDCS			3
#define PORT_INI() 		VS_DDR|=_BV(VS_XCS)|_BV(VS_XRESET)|_BV(VS_XDCS)

#define VS_XCS_H()    	VS_PORT |=  _BV(VS_XCS)
#define VS_XCS_L()    	VS_PORT &= ~_BV(VS_XCS)
#define VS_XRESET_H()   VS_PORT |=  _BV(VS_XRESET)
#define VS_XRESET_L()   VS_PORT &= ~_BV(VS_XRESET)
#define VS_XDCS_H()    	VS_PORT |=  _BV(VS_XDCS)
#define VS_XDCS_L()    	VS_PORT &= ~_BV(VS_XDCS)

extern void VS_SPI_Low(void);
extern void VS_SPI_High(void);

extern unsigned char 	VS_WriteByte(unsigned char CH);
extern unsigned char 	VS_ReadByte(void);
extern void 			VS_WriteCMD(unsigned char addr, unsigned int dat);
extern unsigned int 	VS_ReadCMD(unsigned char addr);
extern void 			VS_WriteDAT(unsigned char dat);
extern unsigned char 	VS_ini(void);
extern void 			VS_SoftReset(void);
extern void				spi_init(void);

#endif
